home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 June: Reference Library / Dev.CD Jun 00 RL Disk 1.toast / pc / technical documentation / develop / develop issue 26 / develop issue 26 code / qt conferencing code / watcher & 'caster / shared.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-10-26  |  2.4 KB  |  114 lines

  1. #include "shared.h"
  2. #include <String.h>
  3. #include <Resources.h>
  4. #include <Fonts.h>
  5. #include <TextUtils.h>
  6.  
  7. /*************************************************** 
  8.  GetUserName 
  9. ****************************************************/
  10. void GetUserName( Str63 userName ) {
  11.  
  12.     StringHandle            sh;
  13.     
  14.     /* this is where the appletalk name is kept in the system */
  15.     sh = GetString(kAppleTalkUserNameID);
  16.     
  17.     BlockMoveData( *sh, userName, *sh[0]+1 );
  18.     
  19.     ReleaseResource( (Handle)sh);
  20. }
  21.  
  22. /*************************************************** 
  23.  DisplayErrorAlert 
  24. ****************************************************/
  25. Boolean        DisplayErrorAlert( ComponentResult result ) {
  26.  
  27.     DialogPtr     alertPtr;
  28.     Handle         hString = nil;
  29.     short        itemHit;
  30.     Str255        errorCode = "\p";
  31.     
  32.     if (( result != noErr) && (result != kTimeToQuit)) {
  33.         alertPtr = GetNewDialog(kErrorAlertID, nil, (WindowRef) -1);
  34.         SetDialogDefaultItem(alertPtr, kOKItem);
  35.         
  36.         if ((result < 32767) && (result > -32766))
  37.             hString = GetResource( kErrorStringType, result );
  38.         else
  39.             hString = nil;
  40.         
  41.         if (hString == nil)
  42.             {
  43.             hString = (Handle)GetString( kGenericError );
  44.             NumToString(result, errorCode);
  45.             }
  46.             
  47.         HLock(hString);
  48.         ParamText( (ConstStr255Param)*hString, errorCode, 0, 0 );
  49.     
  50.         ModalDialog(nil, &itemHit);
  51.         
  52.         HUnlock( hString );
  53.         ReleaseResource( hString );
  54.         DisposeDialog( alertPtr );
  55.     }
  56.     
  57.     if (result == kTimeToQuit)
  58.         return true;
  59.     else
  60.         return false;
  61. }
  62.  
  63. /*************************************************** 
  64.  DoAboutBox 
  65. ****************************************************/
  66. void    DoAboutBox( void ) {
  67.     DialogPtr    aboutBox;
  68.     short        itemHit;
  69.     
  70.     aboutBox = GetNewDialog(kAboutBoxID, nil, (WindowRef) -1);
  71.     
  72.     SetDialogDefaultItem(aboutBox, kOKItem);
  73.  
  74.     SetPort((WindowPtr)aboutBox);
  75.     
  76.     TextFont(applFont);
  77.     
  78.     TextSize( 9 );
  79.  
  80.     ModalDialog(nil, &itemHit);
  81.     
  82.     DisposeDialog(aboutBox);
  83. }
  84.  
  85. /*************************************************** 
  86.  OpenSplashScreen 
  87. ****************************************************/
  88. DialogPtr OpenSplashScreen( void ) {
  89.  
  90.     DialogPtr    splash;
  91.     
  92.     splash = GetNewDialog(kSplashDialogID,nil,(WindowPtr)-1);
  93.     
  94.     if (splash)
  95.         DrawDialog(splash);
  96.         
  97.     return splash;
  98. }
  99.  
  100. /*************************************************** 
  101.  PToCString 
  102. ****************************************************/
  103. void    PToCString( Str63 name, MTCString63 cName)
  104. {
  105.     int i;
  106.     
  107.     for ( i = 0; i < name[0]; i++)
  108.         cName[i] = name[i+1];
  109.         
  110.     cName[i] = 0;
  111. }
  112.  
  113.  
  114.